package com.wink_172.library.view

import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.wink_172.library.R
import com.wink_172.library.model.BaseDataItem

/**
 * 适用于语言切换页面 懒得改了
 */
open class ItemView : RelativeLayout {
    open lateinit var icon_left: ImageView
    open lateinit var content: TextView

    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
    }

    override fun onFinishInflate() {
        super.onFinishInflate()
        initView()
    }

    private fun initView() {
        icon_left = findViewById(R.id.icon_left)
        content = findViewById(R.id.content)
    }

    fun updateContent(titleItem: BaseDataItem) {

//        icon_left.setImageResource(titleItem.getRes());
        content!!.text = titleItem.content
    }

    fun updateActive(active: Boolean) {
        icon_left!!.isActivated = active
    }

    val isCheck: Boolean
        get() = icon_left!!.isActivated
}